<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>手风琴案例</title>
</head>
<style>
    * {
        margin: 0;
        padding: 0;
    }

    /* 去除li 的小圆点 */
    li {
        list-style: none;
    }

    .box {
        margin: 50px auto;
        width: 1200px;
        height: 400px;
        overflow: hidden;
        box-sizing: border-box;
        border: 1px solid red;
    }

    ul {
        width: 1200px;
    }

    ul li {
        width: 240px;
        float: left;
        transition: all 500ms;
    }
</style>

<body>
    <div class="box">
        <ul>
            <li><a href="javascript:;"><img src="./images/1.jpg" alt=""></a></li>
            <li><a href="javascript:;"><img src="./images/2.jpg" alt=""></a></li>
            <li><a href="javascript:;"><img src="./images/3.jpg" alt=""></a></li>
            <li><a href="javascript:;"><img src="./images/4.jpg" alt=""></a></li>
            <li><a href="javascript:;"><img src="./images/5.jpg" alt=""></a></li>
        </ul>
    </div>

    <script>
        // 获取元素 伪数组
        let lis = document.querySelectorAll('li');
        lis.forEach(function (item, index) {
            item.addEventListener('mouseenter', function () {
                // 排他思想 干掉所有人 复活我自己 双重for循环
                lis.forEach(function (item, index) {
                    item.style.width = '100px';
                })
                item.style.width = '800px';
            })
            item.addEventListener('mouseleave', function () {
                lis.forEach(function (item) {
                    item.style.width = '240px';
                })
            })

        })
    </script>
</body>

</html>